package org.example.L04_03_interface;

//接口
class L04_MyMainClass2 {
    public static void main(String[] args) {
//        创建L04_pig2对象
        L04_pig2 myPig2=new L04_pig2();
        myPig2.animalSound();
//        创建L04_dog对象
        L04_dog myDog=new L04_dog();
        myDog.animalSound();

//        接口类对象可以引用[被赋值为]子类创建的对象
//        L04_interface对象引用新创建L04_pig2对象
        L04_interface animal =new L04_pig2();
        animal.animalSound();
//        L04_interface对象引用新创建L04_pig2对象
        L04_interface animal2 =new L04_dog();
        animal2.animalSound();
    }
}

/*
* "D:\A Ahomework\IDEA\jdk\corretto-17.0.12\bin\java.exe" "-javaagent:D:\JetBrains\IntelliJ IDEA 2023\IntelliJ IDEA 2022.3.1\lib\idea_rt.jar=60359:D:\JetBrains\IntelliJ IDEA 2023\IntelliJ IDEA 2022.3.1\bin" -Dfile.encoding=UTF-8 -classpath "D:\A Ahomework\IDEA\javawork\hello_java\target\classes" org.example.L04_03.L04_MyMainClass2
    小猪说：oink-oink!
    小狗说：汪汪汪!
    小猪说：oink-oink!
    小狗说：汪汪汪!

    Process finished with exit code 0
* */
